home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pas_0493.zip / MCGALIB.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-22  |  910b  |  62 lines

  1. Unit MCGALib;
  2.  
  3. interface
  4.  
  5. Procedure SetGraphMode (Num:Byte);
  6. Procedure SetPixel     (X,Y:Integer;Color:Byte);
  7.  
  8. implementation
  9.  
  10. var
  11.   ScreenWide  :  Integer;
  12.   ScreenAddr  :  Word;
  13.  
  14. Procedure SetGraphMode (Num:Byte);
  15. begin
  16.   asm
  17.     mov al,Num
  18.     mov ah,0
  19.     int 10h
  20.     end;
  21.   Case Num of
  22.     $13 : ScreenWide := 320;
  23.     end;
  24.   ScreenAddr := $A000;
  25. end;
  26. {
  27. Function PixelAddr (X,Y:Word) : Word;
  28. begin
  29.   PixelAddr := Y * ScreenWide + X;
  30. end;
  31.  
  32. Procedure SetPixel (X,Y:Integer;Color:Byte);
  33. var
  34.   Ofs    :  Word;
  35. begin
  36.   Ofs := PixelAddr (X,Y);
  37.   Mem [ScreenAddr:Ofs] := Color;
  38. end;
  39. }
  40.  
  41. Procedure SetPixel (X,Y:Integer;Color:Byte);
  42. begin
  43.   asm
  44.     push ds
  45.     mov  ax,ScreenAddr
  46.     mov  ds,ax
  47.  
  48.     mov  ax,Y
  49.     mov  bx,320
  50.     mul  bx
  51.     mov  bx,X
  52.     add  bx,ax
  53.  
  54.     mov  al,Color
  55.     mov  byte ptr ds:[bx],al
  56.     pop  ds
  57.     end;
  58. end;
  59.  
  60. Begin
  61. End.
  62.